package com.privatework.backedserver.controller.hostel;

import com.privatework.common.entity.hostel.HostelInfo;
import com.privatework.common.requestvo.classroom.ClassRoomReqVo;
import com.privatework.common.requestvo.hostel.HostelInfoReqVo;
import com.privatework.common.service.classroom.ClassRoomService;
import com.privatework.common.service.hostel.HostelInfoService;
import com.privatework.common.utils.PageUtil;
import com.privatework.common.utils.ResultVoUtil;
import com.privatework.common.vo.PageVo;
import com.privatework.common.vo.ResultVo;
import com.privatework.common.vo.classroom.ClassRoomHistoryResultVo;
import com.privatework.common.vo.classroom.ClassRoomResultVo;
import com.privatework.common.vo.hostel.HostelInfoResultVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

/**
 * 用户 Controller
 *
 * @author johnny
 * @create 2020-07-10 下午4:08
 **/
@RestController
@Slf4j
@RequestMapping("/hostel")
public class HostelController {

    @Autowired
    private HostelInfoService hostelInfoService;


    @GetMapping("/listByCondition")
    public ResultVo listByCondition(@RequestParam Long userId, PageVo pageVo) {
        pageVo.setPageNumber(pageVo.getPageNumber() - 1);
        Page<HostelInfoResultVo> page = hostelInfoService.listByCondition(userId, PageUtil.initPage(pageVo));
        return ResultVoUtil.success(page);
    }


    @PostMapping("/submitHostelInfoEdit")
    public ResultVo submitHostelInfoEdit(@RequestBody HostelInfoReqVo hostelInfoReqVo) {
        log.info("【hostelInfoReqVo ： {}】  ", hostelInfoReqVo);
        hostelInfoService.submitHostelInfoEdit(hostelInfoReqVo);
        return ResultVoUtil.success();
    }


    @GetMapping("/findHostelInfo")
    public ResultVo findHostelInfo(@RequestParam Long userId) {
        HostelInfoResultVo hostelInfo = hostelInfoService.findHostelInfo(userId);
        return ResultVoUtil.success(hostelInfo);
    }

}